<%-- 
    Document   : delete
    Created on : 1 Jun, 2012, 3:49:32 PM
    Author     : bharat
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<!DOCTYPE html>

<script type="text/javascript">

    var rowVisible = false;

    function toggleDisplay(tbl) {
        var tblRows = tbl.rows;
        for (i = 0; i < tblRows.length-1; i++) {
            if (tblRows[i].className != "headerRow") {
                tblRows[i].style.display = (rowVisible) ? "none" : "table-row";
            }
        }
        rowVisible = !rowVisible;
    }

</script>

<%
    String username = (String) session.getAttribute("usr");

    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    try {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "aksh", "aksh");

        pstmt = con.prepareStatement("select *from posts order by dop desc");
        rs = pstmt.executeQuery();
        for (int i = 0; i < 10; i++) {
            if (rs.next()) {
%>
<table id="theTable<%=i%>" border="1" width="100%">
    <tr class="headerRow" style="display:table-row;">
        <td style="font-weight: bold;font-size: 1.3em;text-transform: uppercase;background-color: #74e868 ">
            <%=rs.getString(3)%>
        </td></tr>
    <tr style="display:none;"><td>
            <%=rs.getString(4)%>
        </td></tr>
    <tr>
        <td>
            Type: <%=rs.getString(2)%> Posted on: <%=rs.getString(5)%> Posted by: <%=rs.getString(8)%>
        </td>
    </tr>
</table>
<div onclick="toggleDisplay(document.getElementById('theTable<%=i%>'))">............click here to read............</div>
<%
    }%><br><%
            }

        } catch (Exception e) {
            response.sendError(555, e.getMessage());
            e.printStackTrace();
        } finally {
            if (rs != null) {
                try {
                    rs.close();
                } catch (Exception e) {
                    response.sendError(555, e.getMessage());
                }
            }
            if (pstmt != null) {
                try {
                    pstmt.close();
                } catch (Exception e) {
                    response.sendError(555, e.getMessage());
                }
            }
            if (con != null) {
                try {
                    con.close();
                } catch (Exception e) {
                    response.sendError(555, e.getMessage());
                }
            }
        }
%>